/**
 * 实现使用函数调用rbt-message组件的逻辑
 */
import { createVNode, render } from 'vue'
import RbtMessage from './rbt-message.vue'

//准备 dom 容器
const div = document.createElement('div')
div.setAttribute('class', 'rbt-message-container')
document.body.appendChild(div)
// 定时器标识
let timer: number = null

export default ({ type, text }: any) => {
  const vnode = createVNode(RbtMessage, { type, text })
  render(vnode, div)
  clearTimeout(timer)
  timer = setTimeout(() => {
    render(null, div)
  }, 3000)
}
